<admintpl file="header" />
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-wrapper">
    <li id="savedimage{id}">
        <input id="photo-{id}" type="hidden" name="pictures[]" value="{filepath}">
        <input id="photo-{id}-name" type="text" name="photos_alt[]" value="{name}" style="width: 160px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
        <a href="javascript:upload_one_image('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#savedimage{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('AdminHomeAds/index')}">首页广告图列表</a></li>
			<li class="active"><a href="{:U('AdminHomeAds/add',array('id'=>empty($item['id'])?'':$item['id']))}" target="_self">新增首页广告图</a></li>
		</ul>
		<form action="{:U('AdminHomeAds/add_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
			<div class="row-fluid">
				<div class="span9">
					<table class="table table-bordered">
						<tr>
							<th>选择分类</th>
							<td>
                                <select name="tid">
								<foreach name="type_list" item="titem">
                                    <option <if condition="$item['tid'] == $titem['id']">selected</if> value="{$titem.id}">
                                        {$titem.title}
                                    </option>
								</foreach>
                                </select>
								<span class="form-required">*</span>
							</td>
						</tr>

                        <tr>
                            <th><b>缩略图</b></th>

                            <td>
                                <div style="text-align: left;">
                                    <input type="hidden" name="picture" id="picture" value="{$item.picture}">
                                    <a href="javascript:upload_one_image('图片上传','#picture');">
                                        <if condition="empty($item.picture)">
                                            <img src="__TMPL__Public/assets/images/default-thumbnail.png" id="picture-preview" width="135" style="cursor: hand"/>
                                            <else />
                                            <img src="{:sp_get_image_preview_url($item['picture'])}" id="picture-preview" width="135" style="cursor: hand"/>
                                        </if>
                                    </a>
                                    <input type="button" class="btn btn-small" onclick="$('#picture-previeww').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#picture').val('');return false;" value="取消图片">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>图片链接</th>
                            <td><input type="text" name="url" id="url" value="{$item.url}" style="width: 400px" placeholder="请输入图片链接"> </td>
                        </tr>
                        <tr>
                            <th>排序</th>
                            <td><input type="text" name="sort" id="sort" value="{$item.sort}" style="width: 400px" > </td>
                        </tr>

					</table>
				</div>

			</div>
			<div class="form-actions">
                <input type="hidden" name="id" value="{$item.id}"/>
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="{:U('AdminPost/index')}">返回</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>

	</body>
</html>